package com.openbravo.pos.printer.javapos;

import com.openbravo.pos.printer.DeviceFiscalPrinter;
import com.openbravo.pos.printer.TicketPrinterException;
import com.openbravo.pos.util.RoundUtils;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JTextField;
import jpos.FiscalPrinter;
import jpos.JposException;

public class DeviceFiscalPrinterJavaPOS extends JPanel
  implements DeviceFiscalPrinter
{
  private String m_sName;
  private FiscalPrinter m_fiscal;
  private JButton jButton1;
  private JButton jButton2;
  private JCheckBox jCheckBox1;
  private JCheckBox jCheckBox2;
  private JCheckBox jCheckBox3;
  private JCheckBox jCheckBox4;
  private JCheckBox jCheckBox5;
  private JPanel jPanel1;
  private JTextField jTextField1;
  private JTextField jTextField2;
  private JTextField jTextField3;
  private JTextField jTextField4;
  private JTextField jTextField5;

  public DeviceFiscalPrinterJavaPOS(String paramString)
    throws TicketPrinterException
  {
    this.m_sName = paramString;
    this.m_fiscal = new FiscalPrinter();
    try
    {
      this.m_fiscal.open(this.m_sName);
      this.m_fiscal.claim(10000);
      this.m_fiscal.setDeviceEnabled(true);
      this.m_fiscal.setCheckTotal(false);
    }
    catch (JposException localJposException)
    {
      throw new TicketPrinterException(localJposException.getMessage(), localJposException);
    }
    initComponents();
  }

  public String getFiscalName()
  {
    return this.m_sName;
  }

  public JComponent getFiscalComponent()
  {
    return this;
  }

  public void beginReceipt()
  {
    try
    {
      this.m_fiscal.beginFiscalReceipt(true);
    }
    catch (JposException localJposException)
    {
    }
  }

  public void endReceipt()
  {
    try
    {
      this.m_fiscal.endFiscalReceipt(false);
    }
    catch (JposException localJposException)
    {
    }
  }

  public void printLine(String paramString, double paramDouble1, double paramDouble2, int paramInt)
  {
    try
    {
      this.m_fiscal.printRecItem(paramString, roundFiscal(paramDouble1 * paramDouble2), (int)(paramDouble2 * 1000.0D), paramInt, roundFiscal(paramDouble1), "");
    }
    catch (JposException localJposException)
    {
    }
  }

  public void printMessage(String paramString)
  {
    try
    {
      this.m_fiscal.printRecMessage(paramString);
    }
    catch (JposException localJposException)
    {
    }
  }

  public void printTotal(String paramString, double paramDouble)
  {
    try
    {
      this.m_fiscal.printRecTotal(0L, roundFiscal(paramDouble), paramString);
    }
    catch (JposException localJposException)
    {
    }
  }

  public void printZReport()
  {
    try
    {
      this.m_fiscal.printZReport();
    }
    catch (JposException localJposException)
    {
    }
  }

  public void printXReport()
  {
    try
    {
      this.m_fiscal.printXReport();
    }
    catch (JposException localJposException)
    {
    }
  }

  public void finalize()
    throws Throwable
  {
    this.m_fiscal.setDeviceEnabled(false);
    this.m_fiscal.release();
    this.m_fiscal.close();
    super.finalize();
  }

  private int roundFiscal(double paramDouble)
  {
    return (int)Math.floor(RoundUtils.round(paramDouble) * 10000.0D + 0.5D);
  }

  private void initComponents()
  {
    this.jButton1 = new JButton();
    this.jPanel1 = new JPanel();
    this.jTextField1 = new JTextField();
    this.jCheckBox1 = new JCheckBox();
    this.jTextField2 = new JTextField();
    this.jCheckBox2 = new JCheckBox();
    this.jTextField3 = new JTextField();
    this.jTextField4 = new JTextField();
    this.jTextField5 = new JTextField();
    this.jCheckBox3 = new JCheckBox();
    this.jCheckBox4 = new JCheckBox();
    this.jCheckBox5 = new JCheckBox();
    this.jButton2 = new JButton();
    setLayout(null);
    this.jButton1.setText("*X Report");
    this.jButton1.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent paramActionEvent)
      {
        DeviceFiscalPrinterJavaPOS.this.jButton1ActionPerformed(paramActionEvent);
      }
    });
    add(this.jButton1);
    this.jButton1.setBounds(30, 10, 130, 23);
    this.jPanel1.setLayout(null);
    this.jPanel1.setBorder(BorderFactory.createTitledBorder("*Receipt Title"));
    this.jTextField1.setText("jTextField1");
    this.jPanel1.add(this.jTextField1);
    this.jTextField1.setBounds(20, 30, 260, 19);
    this.jCheckBox1.setText("jCheckBox1");
    this.jCheckBox1.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    this.jCheckBox1.setMargin(new Insets(0, 0, 0, 0));
    this.jPanel1.add(this.jCheckBox1);
    this.jCheckBox1.setBounds(290, 30, 73, 15);
    this.jTextField2.setText("jTextField2");
    this.jPanel1.add(this.jTextField2);
    this.jTextField2.setBounds(20, 60, 260, 19);
    this.jCheckBox2.setText("jCheckBox2");
    this.jCheckBox2.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    this.jCheckBox2.setMargin(new Insets(0, 0, 0, 0));
    this.jPanel1.add(this.jCheckBox2);
    this.jCheckBox2.setBounds(290, 60, 73, 15);
    this.jTextField3.setText("jTextField3");
    this.jPanel1.add(this.jTextField3);
    this.jTextField3.setBounds(20, 90, 260, 19);
    this.jTextField4.setText("jTextField4");
    this.jPanel1.add(this.jTextField4);
    this.jTextField4.setBounds(20, 120, 260, 19);
    this.jTextField5.setText("jTextField5");
    this.jPanel1.add(this.jTextField5);
    this.jTextField5.setBounds(20, 150, 260, 19);
    this.jCheckBox3.setText("jCheckBox3");
    this.jCheckBox3.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    this.jCheckBox3.setMargin(new Insets(0, 0, 0, 0));
    this.jPanel1.add(this.jCheckBox3);
    this.jCheckBox3.setBounds(290, 90, 73, 15);
    this.jCheckBox4.setText("jCheckBox4");
    this.jCheckBox4.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    this.jCheckBox4.setMargin(new Insets(0, 0, 0, 0));
    this.jPanel1.add(this.jCheckBox4);
    this.jCheckBox4.setBounds(290, 120, 73, 15);
    this.jCheckBox5.setText("jCheckBox5");
    this.jCheckBox5.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    this.jCheckBox5.setMargin(new Insets(0, 0, 0, 0));
    this.jPanel1.add(this.jCheckBox5);
    this.jCheckBox5.setBounds(290, 150, 73, 15);
    this.jButton2.setText("*Z Report");
    this.jButton2.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent paramActionEvent)
      {
        DeviceFiscalPrinterJavaPOS.this.jButton2ActionPerformed(paramActionEvent);
      }
    });
    this.jPanel1.add(this.jButton2);
    this.jButton2.setBounds(20, 220, 130, 23);
    add(this.jPanel1);
    this.jPanel1.setBounds(10, 60, 470, 260);
  }

  private void jButton2ActionPerformed(ActionEvent paramActionEvent)
  {
    printZReport();
  }

  private void jButton1ActionPerformed(ActionEvent paramActionEvent)
  {
    printXReport();
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.printer.javapos.DeviceFiscalPrinterJavaPOS
 * JD-Core Version:    0.6.0
 */